<?php
/**
 * 【订单】列表接口
 * @author webopenfather
 */

// 导入公共库文件
include '../../util/function.php';
include '../../util/db.php';
include '../../util/token.php'; // 这个文件中声明了$userId

// 1. 接受数据（用户名和密码）
$delete = @$_REQUEST['delete'];
if (!$delete) response(400, '参数有误');

// 2. 操作数据库
$pdoStatement = $pdo->query("select * from ecs_order_info where user_id = {$userId} and is_delete = {$delete} order by order_id desc");
$datas = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);

// 过滤日期
$temp = [];
foreach ($datas as $data) {
    $data['add_time_name'] = date('Y-m-d H:i:s', $data['add_time']);
    $data['confirm_time_name'] = date('Y-m-d H:i:s', $data['confirm_time']);
    $data['pay_time_name'] = date('Y-m-d H:i:s', $data['pay_time']);
    $data['shipping_time_name'] = date('Y-m-d H:i:s', $data['shipping_time']);
    $temp[] = $data;
}
 
// 3. 响应结果
response(200, '操作成功', $temp);

